
package org.server.tools;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import org.pojo.User;
import org.server.manage.Server2ClientThread;

/**
 * @author 
 * @time 2012-6-17 下午04:34:24
 *
 */
public class ServerTool {
	public static HashMap<Integer, Server2ClientThread> hm=new HashMap<Integer, Server2ClientThread>();
	public static List<User> onlineUsers= new LinkedList<User>();
	public static  void addClientThread(int userid,Server2ClientThread ct)
	{
		hm.put(userid, ct);
	}
	
	public static Server2ClientThread getClientThread(int userid)
	{
		return (Server2ClientThread)hm.get(userid);
	}
	//返回当前在线的人的情况
	public static String getAllOnLineUserid()
	{
		//使用迭代器完成
		Iterator<User> it=onlineUsers.iterator();
		String res="";
		while(it.hasNext())
		{
			res+=it.next().getNickname().toString()+" ";
			
		}
		System.out.println("在线好友列表:"+res);
		return res;
	}
	public static void addOnlineUser(User u)
	{
		onlineUsers.add(u);
	}
	public static void removeOnlineUser(User u)
	{
		onlineUsers.remove(u);
	}
}
